package com.spudtech
{
    
    import flash.geom.*;
    import flash.display.*;
    
    
    public class SpudScene extends SpudGroup
    {
        
        protected var _world : SpudWorld;
        
        public function SpudScene()
        {
            super([]);
            
            // Icky self-reference
            // It makes sense that the scene's
            // scene is itself, though.
            this.scene = this;
            
            _world = null;
            
        }
        
        public function get world() : SpudWorld
        {
            return _world;
        }
        public function set world(new_world : SpudWorld) : void
        {
            if (_world != null)
            {
                // We already have a world
                // Detach it
                
                _world.destroy();
                
                removeChild(_world);
                
            }
            
            _world = new_world;
            
            if (_world != null)
            {
                // We have a new world
                // Attach it
                
                addChild(_world);
                
                _world.begin();
                
                _world.scene = this;
                
            }
            
            
        }
        
        override public function begin() : void
        {
            super.begin();
        }
        
        override public function destroy() : void
        {
            super.destroy();
        }
        
        
        override public function update() : void
        {
            super.update();
        }
        
    }
    
}
